home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 4
/
Aminet 4 - November 1994.iso
/
aminet
/
comm
/
term
/
vltj5867.lha
/
VLT
/
rexx
/
VLTPhoneDial.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1994-03-27
|
7KB
|
251 lines
/** VLTPhoneDial.rexx
*
* This program is called from the VLTPhoneBook program when the
* Start Dialing Sequence buttom is hit. It then finds the "dial_file"
* and dials the first entry in it. Then it will try establish a
* connection, and if it works, it will wait until the user clicks on
* "Resume Dialing Sequence". If there is no connection, it will continue
* on to the next entry on the list and try all entries until a connection
* is established. The looping will continue until all connections have
* been dialed once, or until the "Abort Dialing Sequence" button is
* hit.
*
* This routine may also be run separately (i.e. it does not have to
* be called from VLTPhoneBook). But it must be called from inside
* VLT. Not however the following:
*
* For this function, if it is run under "AREXX", the port name of VLT
* is given as an argument, because when run under AREXX, the default
* port name is not that of the application.
*
* By W.G.J. Langeveld, February 1992.
*
**/
parse arg vltport
/*
* Add libraries if necessary
*/
if show("l", "rexxarplib.library") = 0 then do
check = addlib('rexxsupport.library', 0, -30, 0)
check = addlib('rexxarplib.library', 0, -30, 0)
end
/*
* First define some text strings and procedures. Here we assume
* a Hayes compatible modem. If you have a different modem, you should
* be able to change just the following three strings.
*
* Here's a set of responses that is given by Hayes modems:
*/
response = "OK"
connectstr = "CONNECT"
busystr = "BUSY"
nocarrierstr = "NO CARRIER"
/*
* Here is a hangup script that may work for Hayes modems.
* You could also just drop DTR if that works for you:
*
* hangupscript = "hangup"
*/
hangupscript = "$vltphone_wait: on (OK) continue; send (+++); delay 2; "
hangupscript = hangupscript || "send (ATH*R); delay 15; on (OK) (); send (*R*R)"
/*
* This script I use to get the modem in line after changing parity.
* You may be able to get away with not doing anything, like this:
*
* retrainscript = ""
*/
retrainscript = "$vltphone_wait: on (OK) exit; send (AT*R); $1: delay .5; "
retrainscript = retrainscript || "send (AT*R); goto $1"
/*
* Okay, to the real work. First set the port to that of this invocation
* of VLT.
*/
address value vltport
cols = ScreenCols(vltport)
if cols == -1 then do
vltscreen = ""
cols = ScreenCols()
rows = ScreenRows()
end
else do
vltscreen = vltport
rows = ScreenRows(vltscreen)
end
/*
* Check if we're set up correctly without requesters coming up.
* If not, call the setup program
*/
call pragma('W', 'NULL')
if ~exists("VLTPhoneBook:") then do
"@VLTPhoneSetup.rexx"
exit
end
/*
* Open the dial file
*/
if open(input, "VLTPhoneBook:T/dial_file", "r") = 0 then do
"message (Couldn't read dial file); delay 1.5; message"
exit
end
/*
* Read the dial file
*/
do i = 1
files.i.filename = readln(input)
files.i.done = 0
if eof(input) ~= 0 then leave
end
call close(input)
files.0 = i - 1
if files.0 = 0 then do
"message (Dial file has no entries)"
exit
end
/*
* Read all the phonebook files that are called for in the dial file
*/
do i = 1 to files.0
if open(input, files.i.filename, "r") = 0 then do
"message (Couldn't read file "files.i.filename")"
exit
end
files.i.name = readln(input)
files.i.address = readln(input)
files.i.city = readln(input)
files.i.phone = strip(readln(input))
files.i.modem = strip(readln(input))
files.i.baud = strip(readln(input))
files.i.parity = strip(readln(input))
files.i.fcmds = strip(readln(input))
files.i.lcmds = strip(readln(input))
files.i.notes = readln(input)
call close(input)
end
/*
* Main dialing loop
*/
i = 1
donefiles = 0
do forever
if files.i.done = 0 then do
/*
* Preset the cancel flag to something, announce who we're calling,
* set baud and parity. Then do the first (predial) set of commands
* if any.
*/
vlt.CANCELFLAG = "start"
if length(files.i.baud) > 0 then "baud "files.i.baud
if length(files.i.parity) > 0 then "parity "files.i.parity
if length(files.i.fcmds) > 0 then ""files.i.fcmds
/*
* We may have changed parity, and the modem may need some time.
*/
if retrainscript ~= "" then retrainscript
if upper(vlt.CANCELFLAG) = "ABORT" then do
"message (Aborted!)"
exit 0
end
"message; message (Dialing "files.i.name"...)"
/*
* Send the modem string if any.
*/
if length(files.i.modem) > 0 then do
"$vltphone_wait: on ("response") continue; send ("files.i.modem"*R*N); delay 5"
if upper(vlt.CANCELFLAG) = "ABORT" then do
"message (Aborted!)"
exit 0
end
end
/*
* Set up the "CONNECT" trap. Make it start the second (postdial)
* set of comamnds if there are any.
*/
if length(files.i.script) > 0 then do
"trap add 314 install ("connectstr") ("files.i.lcmds"; cancel $vltphone_wait connect)"
end
else do
"trap add 314 install ("connectstr") (cancel $vltphone_wait connect)"
end
/*
* Set up the BUSY and NO CARRIER traps. Note the use of the new feature
* of the CANCEL command.
*/
"trap add 315 install ("busystr") (cancel $vltphone_wait busy)"
"trap add 316 install ("nocarrierstr") (cancel $vltphone_wait nocarrier)"
/*
* Send dial string and wait until the "pause" gets cancelled
*/
if length(files.i.phone) > 0 then do
"$vltphone_wait: send ("files.i.phone"*r); pause"
end
else do
"$vltphone_wait: pause"
end
/*
* We got cancelled. See which event cancelled us.
*/
event = vlt.CANCELFLAG
/*
* Remove the traps but only the ones we used.
*/
"trap remove 314 315 316"
/*
* If we got connected, close the panel if it exists, increment the
* number of successful connections.
*/
if upper(event) = "CONNECT" then do
files.i.done = 1
if showlist('p', VLTPHONEBOOK) ~= 0 then do
"message"
address VLTPHONEBOOK quit
end
donefiles = donefiles + 1
if donefiles = files.0 then exit 0
/*
* Wait until we get called again.
*/
"$vltphone_wait: pause"
event = vlt.CANCELFLAG
end
/*
* If we need to resume, send a few hangups.
*/
if upper(event) = "RESUME" then hangupscript
/*
* Check if we got an abort event. If so, quit.
*/
if upper(event) = "ABORT" then do
"message (Aborted!)"
exit 0
end
/*
* If the hangupscript was interrupted, also abort
*/
if upper(vlt.CANCELFLAG) = "ABORT" then do
"message (Aborted!)"
exit 0
end
end
/*
* Increment the list pointer, roll back to 1 if needed
*/
i = i + 1
if i > files.0 then i = 1
end
/*
* We don't get here
*/